package com.example.security.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.security.util.StaticUtil;

@Controller
public class LoginController {

	
	@ResponseBody
	@RequestMapping(value="/goLogin")
	public Map<String,Object> goLogin(HttpServletResponse response) throws IOException{
		Map<String,Object> result=new HashMap<>();
		result.put("code", 200);
		//StaticUtil.generateFile("index", "E:\\index", new HashMap<>());
		response.addHeader("Authentication", "aaaaa");
		return result;
	}
	
	@RequestMapping(value="/login")
	public String goTest() throws IOException {
		Map<String, Object> params=new HashMap<>();
		params.put("name", "gaobenshang");
		//StaticUtil.generateFile("test", "E:\\test", params);
		return "test";
	}
	
	@RolesAllowed("ROLES_ADMIN")
	@ResponseBody
	@RequestMapping(value="/user/info")
	public String hhh() {
		return "hhhhhh";
	}
}
